package main.test.SparkAPI.Baics.classApi.HTTPserver

object MyCaluculator {

  /**
   * Impl anonymous funcs
   * code using concise notation for anonoyFuncs
   *
   * find new type of func :anonymous
   * it is a func that you define quickly and concisely.
   * first, it may seem just an alter to standard scal func,
   * but you find hat they are handy when combined with
   * func called higher order.
   * The concept of anonymous func is not unique to scala,
   * java8+ and Python refer to it as lambda.
   * use a kind of anonymous func called partial to define you http
   * server's routes
   */
  /**
   * consider two func to sum and subtract 2 integers:
   * def sum(a:Int,b:Int) :Int = a+b
   * def subtract(a:Int,b:Int):Int = a-b
   * which part have in common
   * a concise way to achieve these?
   */

  //func vs anony func

  def sum(a: Int, b: Int): Int = a + b
  def subtract(a: Int, b: Int): Int = a - b
  def multiply(a: Int, b: Int): Int = a * b
  def divide(a: Int, b: Int): Int = a / b
  def negate(a: Int): Int = subtract(0, a)

}
